'use strict';

class AppBootHook {
  constructor(app) {
    this.app = app;
    this.app.ossClient = {};
  }

  /**
   * 服务器正在监听。
   */
  async serverDidReady() {
    console.log('服务器正在监听.......');
    const ctx = this.app.createAnonymousContext();
    await this.refreshMenu(ctx);
  }

  /**
   * 更新公众号菜单
   */
  async refreshMenu(ctx) {
    this.app.logger.info('初始化菜单...');
    await ctx.service.wechat.createMenu();
    this.app.logger.info('初始化菜单完成');
  }
}

module.exports = AppBootHook;
